package top.code.user.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import top.code.user.entity.User;
import top.code.user.service.UserService;

import javax.servlet.http.HttpSession;

/**
 * Created by setsun on 2017/9/20.
 */

@Controller
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/home")
    public String home(){
        return "home";
    }

    @RequestMapping("/userinfo")
    @ResponseBody
    public User getUser(HttpSession session){
        User user = (User) session.getAttribute("userinfo");
        return user;
    }

    /**
    *@Author benson {www.honey520.com}
    *@Date 2017/9/24 15:30
    *@Description 退出方法
    */
    @RequestMapping("/logout")
    public String logout(HttpSession session){
        session.invalidate();
        return "login";
    }


}
